#!/usr/bin/python
# -*- coding: utf-8 -*-
import urllib,urllib2,re,os,xbmc

#author:
#elypter
#-mail:elypter@yahoo.de
#
debug=1
dstr="##*oracl2*novamov*"


def check(url):
	#not used atm
	if url.rfind("novamov"):
		return 1
	else:
		return 0
def get_regexp():
	return "http\://www\.novamov\.com/(?:embed\.php\?v\=|video/)([0-9a-z]*)"
def get_name():
	return "novamov"
def join(id):
	return "http://www.novamov.com/embed.php?v="+id
def get_link1(url):
	#takes an videopage-url of megavideo
	#
	#returnes the service/mirror name, the url that will be passed over to get_link2, the url of the verification code
	
	if debug > 0: print dstr+" getting: "+ str(url)
	
	req = urllib2.Request(url)
	req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
	response = urllib2.urlopen(req)
	page=response.read()
	response.close()
	
	#print page
	
	link = re.compile('"file","([^<>"]*)"').findall(page.lower())
	#return ('novamov',link[0],'')
	return ("got",link[0],'','','','','novamov')

def get_link2(param,code):
	#should take the url that get_link1 returned
	#
	#returnes the video url
	return ("got",param,'','','','','novamov')
